﻿package net.wangit.jdbc.database;

import java.util.HashMap;
import java.util.Map;

import net.wangit.jdbc.sqltype.SqlType;
import net.wangit.jdbc.sqltype.SqlTypeFactory;


public class TypeMapping {

	private Map<Integer, Integer> sqlTypes;
	private Map<Integer, String> sqlTypeNames;

	public TypeMapping() {
		sqlTypes = new HashMap<Integer, Integer>();
		sqlTypeNames = new HashMap<Integer, String>();
	}

	public void put(int typecode, int sqlType, String typeName) {
		sqlTypes.put(new Integer(typecode), new Integer(sqlType));
		sqlTypeNames.put(new Integer(typecode), typeName);
	}

	public SqlType getSqlType(int typecode) {
		Integer sqlTypeCode = sqlTypes.get(new Integer(typecode));
		return SqlTypeFactory.getSqlType(sqlTypeCode.intValue());
	}

	public String getSqlTypeName(int typecode) {
		return sqlTypeNames.get(new Integer(typecode));
	}
}
